#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include "task.hpp"
#include "thread_pool.hpp"

using namespace std;
using namespace ns_tp;
using namespace ns_task;

void* Rountine(void* args)
{
    thread_pool<task>* tp = (thread_pool<task>*)args;

    while (1)
    {
        int a = rand() % 100, b = rand() % 100;
        task t(a, b);
        tp->push(t);
        sleep(1);
    }
}

int main()
{
    srand(time(nullptr));
    thread_pool<task>* tp = new thread_pool<task>();
    tp->init();
    pthread_t tid;
    pthread_create(&tid, nullptr, Rountine, (void*)tp);
    pthread_join(tid, nullptr);
    return 0;
}